




  <div class="successfull" style="display:<?php echo ($this->session->flashdata('userMesg') ? 'block' : 'none') ?> ">
                <?php echo $this->session->flashdata('userMesg'); ?>  
            </div>
            	
	 <div class="headingBox"  style="padding-top:10px;">
                <div class="FloatLeft"><img src="<?php echo imageUrl(); ?>red_leftRound.jpg" width="5" height="24" alt="" /></div>
              <div class="red_midRound" style="width:992px;"><span class="red_midRound" style="width:992px;"><?php echo $page_heading; ?></span></div>
                <div class="FloatLeft"><img src="<?php echo imageUrl(); ?>red_rightRound.jpg" width="5" height="24" alt="" /></div>
            </div>
            

            <div>
            
            <div id="error_msg_div">
			<?php  if( isset($error_arr) && count($error_arr) > 0 ) {
                        foreach( $error_arr as $err) {
                            echo '<div class="errorMsg_1" style="" align="center">'.$err.'</div>';	
                        }
                    }
                    //vardump($error_arr); 
                ?>
            </div>
            
             <?php 

			?>
             <form method="post" action="<?php echo base_url().$this->uri->segment(1); ?>/priority<?php echo "/$ext" ; ?>" onsubmit="return validate();">
               <input name="sbmt" id="sbmt" value="1" type="hidden">
             
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td><table width="100%" cellspacing="5" cellpadding="2" class="subContentTable">
                        <tr>
                        <td height="20" class="head3" width="30px;">Primary</td>
                        <td height="20" class="head3">Skill Name</td>
                        <td height="20" class="head3" colspan="2">Priority</td>
                       </tr>
                        <?php 
						$cnt = 0;
						foreach($results as $row) 
						{
							$bg_color = ($cnt%2 == 0) ? "#ffffff" : "#fff1d5";
							$cnt++;
							$skill = $row->queue_name;
							$id = $row->uniqueid;
							$penalty = (int)$row->penalty;

							$checked = '';
							$slider_disable = '';
							$txt_readonly = '';
							if($skill == $row->primary_skill){
								$checked = "checked='checked'";
								$slider_disable = "disabled: true,";
								$txt_readonly = "readonly='readonly'";
							} 
							
						?>
                        <tr bgcolor="<?php echo $bg_color; ?>">
                        
                        <td align="left" height="20" width="15%">
                        	<input type="hidden" class="ids_hidden" name="ids[]" value="<?php echo $id; ?>"  />
							<input type="radio" class="skill_radio" value="<?php echo $skill."~".$id; ?>"  name="primary_skill[]" id="<?php echo $id; ?>"  onclick="onClickPrimarySkill('<?php echo $id; ?>')"  <?php echo $checked; ?>  />
                        </td>
                        <td height="20" align="center" width="10%"><?php echo $skill; ?></td>
                        <td height="20" align="center" width="60%">
                        	<div id="slider_<?php echo $id; ?>"></div>
                            	
                        </td>
                        <td height="20" align="center" valign="middle" width="10%" >
                        	<input type="text" <?php echo $txt_readonly; ?> class="class_txt_priority" name="penalty[<?php echo $id; ?>]" id="txt_<?php echo $id; ?>"  onkeypress="return intOnly(this,event);"  value="<?php echo $penalty; ?>" />
                        </td>
                        <script>
							$(function() {
								 slider_obj_<?php echo $id; ?> = $( "#slider_<?php echo $id; ?>" ).slider({ min: 0,
														max: 100,
														range: "min",
														slide: function(event, ui) 
														{
															$("#txt_<?php echo $id; ?>").val(ui.value);
														},
														<?php echo $slider_disable; ?>
														value : <?php echo $penalty; ?>  });
							});
							
							$('#txt_<?php echo $id; ?>').blur(function() 
							{
								txtVal = $('#txt_<?php echo $id; ?>').val();
								//if not a number
								if(isNaN(txtVal))
								{
									$('#txt_<?php echo $id; ?>').val(0);
								}
								else if(parseInt(txtVal, 10) > 100)
								{
									$('#txt_<?php echo $id; ?>').val(100);
								}
								else if(parseInt(txtVal, 10) < 0)
								{
									$('#txt_<?php echo $id; ?>').val(0);
								}
																								
																								
								slider_obj_<?php echo $id; ?>.slider( "value", $('#txt_<?php echo $id; ?>').val()); 
 							} );
							
							
							</script>
                      </tr>
                        <?php 
							}
						?>
                        
                        <?php 
							if( count($results) == 0 ) {
								echo "<tr><td align='center' colspan='4'> No record(s) found. </td></tr>";	
							}
						?>
                       
                      <tr>
            	          	<td colspan="4" align="left">
        	            	    <input value="" class="backBtn" onclick="location.href='<?php echo base_url().$this->uri->segment(1); ?>';" type="button">
    	            	        <?php  if( count($results) > 0 ) { ?>
                                <input value="" class="submitBtn" type="submit">
                                <?php } ?> 
	            	        </td>
                      </tr>
                        
                        
                      </table></td>
                  </tr>
                  <tr>
                  	<td colspan="5" align="center"> <ul class="paging"> <?php echo  $this->pagination->create_links();  ?> </ul> </td>
                  </tr>
              </table>
              </form>
				</div>
  </div>           
  
  <script>
							
							
							function onClickPrimarySkill(id)
							{
								
								/*primary_skill = $('.skill_radio');
								for( i=0; i< primary_skill.length; i++ ) 
								{
									//primary_skill[i].checked = false
								}
								//$('#'+id).prop("checked", true);*/
								
								$('#slider_'+id).slider("value", 10);
								$('#txt_'+id).val(10);

								ids  = $('.ids_hidden');
								if( ids.length > 0 ) 
								{
									for( i = 0; i < ids.length; i++ ) {
										$( "#slider_"+ids[i].value ).slider({ disabled: false });
										$('#txt_'+ids[i].value).prop("readonly",false);
									}
								}
								
								$( "#slider_"+id ).slider({ disabled: true });
								$('#txt_'+id).prop("readonly",true);
							}
							
							function validate()
							{
								error_msg = '';
								var priority_arr = new Array();
								var priority_empty = false;
								var primary_skill_priority_id = '';
								
								all_ids  = $('.ids_hidden');
								
								primary_skill_flag = false;
								//primary_skill = document.getElementsByName('primary_skill[]');
								primary_skill = $('.skill_radio');
								for( i=0; i< primary_skill.length; i++ ) {
									if( primary_skill[i].checked ) {
										primary_skill_flag = true;
										primary_skill_priority_id  = primary_skill[i].id;
									}	
								}
									
								
								if( ! primary_skill_flag ) {
									error_msg += '<div class="errorMsg_1" align="center">Please select primary skill</div>';
								}
								
								
								for( i = 0; i < all_ids.length; i++ ) {
									if( $('#txt_'+all_ids[i].value).val() == '' )
									{
										priority_empty = true;	
									}
									else
									{
										priority_arr.push($('#txt_'+all_ids[i].value).val());
									}
								}
								
									
								if( priority_empty ) {
									error_msg += '<div class="errorMsg_1" align="center">Please enter priority</div>';	
								}
								else
								if( arrHasDuplicate(priority_arr) )
								{
									error_msg += '<div class="errorMsg_1" align="center">Priorities can not be same</div>';	
								}
								
								any_priority_less_than_zero = false;
								any_priority_less_then_primaty = false;
								
								if( ! priority_empty ) 
								{
								
									all_priorities = $('.class_txt_priority');
									
									for( i = 0 ; i < all_priorities.length; i++ ) 
									{
										if( parseInt(all_priorities[i].value, 10) < 1 ) 
										{
											any_priority_less_than_zero = true;
										} 
										
										if( all_priorities[i].id != 'txt_'+primary_skill_priority_id ) 
										{
											if(parseInt(all_priorities[i].value,10) < parseInt($('#txt_'+primary_skill_priority_id).val(),10) )
											{
												any_priority_less_then_primaty =  true;
											}
										}
 										
									}
										
								}
								
								
								if( any_priority_less_than_zero ) {
									error_msg += '<div class="errorMsg_1" align="center">Priority must be greater than zero</div>';	
								}
								
								if( any_priority_less_then_primaty ) {
									error_msg += '<div class="errorMsg_1" align="center">Other priority must be greater than primary skill priority</div>';	
								}
							
							
								if( error_msg == '' ) {
									$("#error_msg_div").html('');
									$("#error_msg_div").hide();	
									return true;
								} else {
									$("#error_msg_div").html(error_msg);
									$("#error_msg_div").show();	
									return false;
								}
						
							}

							
						</script>